﻿namespace BM.Tools.WebControls.MForm.Controls.Additions
{
    using System.Web.UI;

    /// <summary>
    /// An abstract class that reflects a part of the description definition 
    /// in HTML DOM tree
    /// </summary>
    public abstract class DescriptionChunk
    {
        /// <summary>
        /// renders the control
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        public void RenderControl(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.B);
            RenderContent(writer);
            writer.RenderEndTag();
        }

        /// <summary>
        /// adds attributes to the node
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected virtual void AddAttributesToRender(HtmlTextWriter writer)
        {
            writer.AddAttribute("class", GetType().Name);
        }

        /// <summary>
        /// renders the content
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected virtual void RenderContent(HtmlTextWriter writer)
        {
        }
    }
}